package com.example.fcm;

import java.net.HttpURLConnection;
import java.net.URL;

public class GoogleConnectionTest {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://www.google.com");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setConnectTimeout(5000); // 设置连接超时时间为 5 秒
            connection.setReadTimeout(5000);    // 设置读取超时时间为 5 秒

            int responseCode = connection.getResponseCode();
            if (responseCode == 200) {
                System.out.println("Successfully connected to google.com");
            } else {
                System.out.println("Failed to connect to google.com, response code: " + responseCode);
            }
        } catch (Exception e) {
            System.out.println("Error connecting to google.com: " + e.getMessage());
        }
    }
}
